package pay.commont;

public enum MessageType {
    SYSTEM(0, "系统消息"),
    CLUB(1, "俱乐部消息"),
    FEEDBACK(2, "反馈消息"),
    MANAGE(3, "管理端信息"),
    POST(4, "邮寄消息");

    private final int code;
    private final String desc;

    MessageType(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据 code 获取对应的枚举值
     */
    public static MessageType getByCode(int code) {
        for (MessageType type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }

    /**
     * 根据 desc 获取对应的枚举值
     */
    public static MessageType getByDesc(String desc) {
        for (MessageType type : values()) {
            if (type.desc.equals(desc)) {
                return type;
            }
        }
        return null;
    }
}